package strategy

type IStrategy interface {
	Name() string // 策略名称
	Run()         // 运行策略
}

// 策略注册表
var strategies = make(map[string]IStrategy)

// Register 注册策略
func Register(name string, strategy IStrategy) {
	if _, ok := strategies[name]; ok {
		panic("strategy: " + name + " already registered")
	}

	// 注册策略
	strategies[name] = strategy
}

func Run() {
	// 运行策略
	for _, strategy := range strategies {
		go strategy.Run()
	}
}
